﻿var um = UM.getEditor('myEditor', {
	//toolbar: ['undo redo | bold italic underline emotion image'], 
	toolbar:[
		'undo redo | bold italic underline strikethrough horizontal | superscript subscript | forecolor backcolor | removeformat |',
		'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize |' ,
		'justifyleft justifycenter justifyright justifyjustify |',
		'emotion image |',
		'preview drafts'
	],
	serverUrl: "http://upload.ibaotu.com/?c=ImgUploadForum",
	imageUrl: "http://upload.ibaotu.com/?c=ImgUploadForum",
	imagePath: "http://upload.ibaotu.com/",
	fixedImagePath: "http://upload.ibaotu.com/",
	imageFieldName: "upfile",
	imageMaxSize: 2048,
	imageAllowFiles: [".png", ".jpg", ".jpeg", ".gif", ".bmp"],
});

function floor_left() {
	if ($('.floor-left').length > 0) {
		// 重置左边栏高度
		$('.floor-left').each(function(i, ele){
			$(this).css('height', $(this).siblings('.floor-right').innerHeight());
		});
	}
}

if($('.home-posting').length > 0) {
	$('.home-posting').click(function(){
		$('html,body').animate({
			scrollTop: $('.posting-tit').offset().top-100
		},300);
	});
}
function addForum(uid) {
	if (uid=='0') {
		alert('请先登录');
	} else {
		var title = $('.newPost-tit').val();
		var message = um.getContent();
		var txt = um.getContentTxt();
		if(title=='') {
		   alert('标题不能为空');
		} else if(title.length>50){
			alert('标题长度不得超过50个字符');
		} else if(message=='') {
			alert('内容不能为空');
		} else {
			$.post('http://ibaotu.com/?m=forum&a=add',{"title":title,"message":message,"abstract":txt},function(data){
				if(data.status==1) {
					alert('发表成功，请耐心等待审核');
					window.location.reload()
				} else {
					alert(data.info);
				}
			},'json');
		}
	}
}
function replyForum(tid) { 
	if (tid) { 
		var message = um.getContent();
		if(message=='') {
			alert('回复不能为空');
		} else {
			$.post('http://ibaotu.com/?m=forum&a=reply',{"tid":tid,"message":message},function(data){
				if(data.status==1) {
					alert('回复成功');
					window.location.reload()
				} else {
					alert(data.info);
				}
			},'json');
		}
	} else {
		return false;
	}
}
function getReply(page) {
	var tid = $('#tid').val();
	if (page&&tid) { 
		$('asy').load('http://ibaotu.com/?m=forum&a=getreply&p='+page+'&tid='+tid,function(){
			floor_left();
		});
	}
}